import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
import time

# 配置
DOMAINS = ["domain1.us.kg", "domain2.us.kg"]  # 替换为你的域名列表
LOGIN_URL = "https://register.us.kg/panel/main"  # 登录页面URL

def login(driver, email, password):
    driver.get(LOGIN_URL)
        time.sleep(2)  # 等待页面加载

            # 输入邮箱
                email_input = driver.find_element(By.NAME, "email")
                    email_input.send_keys(email)

                        # 输入密码
                            password_input = driver.find_element(By.NAME, "password")
                                password_input.send_keys(password)

                                    # 点击登录按钮
                                        login_button = driver.find_element(By.XPATH, "//button[@type='submit']")
                                            login_button.click()
                                                time.sleep(5)  # 等待登录完成

                                                def renew_domain(driver, domain):
                                                    # 假设续期页面和操作与之前类似
                                                        driver.get(f"https://register.us.kg/panel/renew/{domain}")
                                                            time.sleep(2)

                                                                # 假设续期按钮的ID或类名是"renew-button"
                                                                    renew_button = driver.find_element(By.ID, "renew-button")
                                                                        renew_button.click()
                                                                            print(f"域名 {domain} 续期操作已完成！")

                                                                            def main():
                                                                                # 交互式输入邮箱和密码
                                                                                    email = input("请输入您的邮箱账号: ")
                                                                                        password = input("请输入您的密码: ")

                                                                                            # 设置Chrome选项
                                                                                                options = uc.ChromeOptions()
                                                                                                    driver = uc.Chrome(options=options)

                                                                                                        try:
                                                                                                                login(driver, email, password)
                                                                                                                        for domain in DOMAINS:
                                                                                                                                    renew_domain(driver, domain)
                                                                                                                                        finally:
                                                                                                                                                driver.quit()

                                                                                                                                                if __name__ == "__main__":
                                                                                                                                                    main()
                                                                                                                                                    